﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using VIT.Web.UI;
using VIT.Library.Web;
using VIT.DataHelper.DataAccess;

namespace VIT.Wedding.Components.Product
{
    public partial class Style : VITComponent
    {
        private string CatID
        {
            get { return string.IsNullOrEmpty(Page.Request.Params.Get("CatID")) ? "0" : Page.Request.Params.Get("CatID"); }
        }

        private bool LoadModule(Web.Controls.Skin skin, string moduleName, Dictionary<string, string> pars, string title = "")
        {
            var module = LoadControl(URL.appPath + "Modules/" + moduleName + "/" + moduleName + ".ascx") as VITModule;
            var controlSkin = LoadControl(URL.appPath + "Skins/" + skin.SkinName + ".ascx") as VITSkin;
            controlSkin.Title = title;
            module.Params = pars;
            skin.Controls.Add(controlSkin);
            var container = controlSkin.FindControl("PlaceHolderContent");
            container.Controls.Add(module);
            return true;
        }

        private void LoadSkinEmptyTop()
        {
            var pars = new Dictionary<string, string>();
            pars["Position"] = "PromotionCenter";
            pars["Width"] = "749";
            pars["Height"] = "50";
            pars["HasLink"] = "false";
            LoadModule(SkinEmptyTop, "Logo", pars);
        }
        private void LoadSkinBanner()
        {
            var pars = new Dictionary<string, string>();
            //if (CatID == "25")
            //{
            //    pars["Position"] = "BannerThiepCuoi";
            //}
            //else
            //{
            //    pars["Position"] = "Banner";
            //}
            pars["Position"] = "BannerStyles";
            pars["Width"] = "732";
            pars["Height"] = "301";
            LoadModule(SkinBanner, "SlideshowNumber", pars);
        }
        private void LoadSkinColor()
        {
            var pars = new Dictionary<string, string>();
            pars["ColorNStyleModuleName"] = "Styles";
            LoadModule(SkinColor, "ColorNStyle", pars);
        }
        private void LoadSkinChooseType()
        {
            var pars = new Dictionary<string, string>();
            pars["ColorNStyleModuleName"] = "Colors";
            pars["Appropriate"] = "0";
            LoadModule(SkinChooseType, "ColorNStyleScroll", pars);
        }


        protected Product_Color ColorObj
        {
            get { return ViewState["ColorObj"] as Product_Color; }
            set { ViewState["ColorObj"] = value; }
        }

        protected new void Page_PreInit(object sender, EventArgs e)
        {
            base.Page_PreInit(sender, e);
            //LoadSkinEmptyTop();
            LoadSkinBanner();
            LoadSkinColor();
            LoadSkinChooseType();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}